//
//  DXUserIfoModel.swift
//  weiBoOfSwift
//
//  Created by simon on 15/12/7.
//  Copyright © 2015年 simon. All rights reserved.
//

import UIKit


class DXAccountModel: NSObject ,NSCoding{
    
//    用户token值
    var access_token:String?
    //    过期时间单位秒
    var expires_in:NSTimeInterval = 0{
        didSet{
            expires_date = NSDate(timeIntervalSinceNow:expires_in )
            
        }
    }
    var remind_in:NSTimeInterval = 0
//    用户ID
    var uid:Int = 0
//    用户头像
    var avatar_large:String?
//    用户昵称
    var screen_name:String?
//   用户token到期日期
    var expires_date:NSDate?
    
    init(dict:[String:AnyObject]) {
        super.init()
        
        setValuesForKeysWithDictionary(dict)
    }
    
    override func setValue(value: AnyObject?, forUndefinedKey key: String) {
        logPrint("********\(key)can not find!!!!!!!!")
        
    }
    
//    override var description:String{
//    let dic = ["access_token","uid"]
//        
//        return dictionaryWithValuesForKeys(dic).description
//    }
//    
    
    // MARK: - 归档代理
    func encodeWithCoder(aCoder: NSCoder) {
         aCoder.encodeObject(access_token, forKey: "access_token")
//         aCoder.encodeObject(uid, forKey: "uid")
         aCoder.encodeObject(avatar_large, forKey: "avatar_large")
         aCoder.encodeObject(screen_name, forKey: "screen_name")
          aCoder.encodeObject(expires_date, forKey: "expires_date")
      

    }
    // MARK: - 解档代理
    required init?(coder aDecoder: NSCoder) {
        
     access_token = aDecoder.decodeObjectForKey("access_token") as? String
     avatar_large = aDecoder.decodeObjectForKey("avatar_large") as? String
     screen_name = aDecoder.decodeObjectForKey("screen_name") as? String
     expires_date = aDecoder.decodeObjectForKey("expires_date") as? NSDate
    }
    
    
}
